#import "XMLInternalNode.h"

@implementation XMLInternalNode

@synthesize key;
@synthesize attributes;

- (id)initWithParent:(XMLNode *)p key:(NSString *)k
    attributes:(NSDictionary *)attr;
{
    if (self = [super initWithParent:p])
    {
        [self setKey:k];
        [self setAttributes:attr];
    }
    return self;
}

- (NSString *)generateXML
{
    NSMutableString *attrs = [[NSMutableString alloc] init];
    for (NSString *k in attributes)
        [attrs appendFormat:@" %@=\"%@\"", k, [attributes objectForKey:k]];
    return [NSString stringWithFormat:@"<%@%@>%@</%@>", key, attrs,
            [super generateXML], key];
}

@end
